#include "Led.h"


UI_System_S UI_System;
bool LED[19][16] = {0};

bool wifi_state=0;  //wifi状态显示
bool bluetooth_state=0;  //蓝牙状态显示
bool battery_state=0;  //电量状态显示
bool igniter_display_state=0;  //点火棒状态显示
bool motor_display_state=0;  //马达状态显示
bool fan_display_state=0;  //风扇状态显示
bool feed_display_state=0;  //进料状态显示
bool logo_state=0;  //logo状态显示
bool hengang_state=0;  //横杠状态显示
bool ACT_state=0;  //ACT状态显示
bool SET_state=0;  //SET状态显示
bool fire_state=0;  //火焰图标状态显示
bool P1_state=0;  //P1状态显示
bool P2_state=0;  //P1状态显示
bool P3_state=0;  //P1状态显示
bool Timer_state=0;  //定时状态显示
bool starving_state=0;  //缺料状态显示



bool wifi_OnOff=0;  //wifi闪烁
bool bluetooth_OnOff=0;  //蓝牙闪烁
bool igniter_OnOff=0;  //点火棒闪烁
bool motor_OnOff=0;  //马达闪烁
bool fan_OnOff=0;  //风扇闪烁
bool Temperature_Set_OnOff=0;  //温度设置闪烁
bool time_hour_OnOff=0;  //时设置闪烁
bool time_minute_OnOff=0;  //分设置闪烁

bool temp_set_set = 0; //1:设置温度正常显示，0：熄灭  不断切换达到闪烁效果
bool time_hour_set = 0;  //1:定时 时 正常显示，0：熄灭  不断切换达到闪烁效果
bool time_minute_set = 0;   //1:定时 分 正常显示，0：熄灭  不断切换达到闪烁效果
bool time_icon = 0;   //时间图标  ：

bool error = 0;  //故障状态
bool Temperature_display_updata = 0;

uint8_t Temp_icon_state=0; //温度图标状态 0，不显示  1，摄氏度  2，华氏度
uint8_t menu_key_state=0; //菜单按键图标状态 0，不显示  1，白色  2，蓝色
uint8_t feed_key_state=0; //进料按键图标状态 0，不显示  1，白色  2，蓝色
uint8_t Onoff_key_state=0; //开关按键图标状态 0，不显示  1，白色  2，蓝色

uint16_t Temperature = 0;//温度
uint16_t Temperature_P1 = 0;//P1温度
uint16_t Temperature_P2 = 0;//P2温度
uint16_t Temperature_P3 = 0;//P3温度
uint16_t Temperature_P4 = 0;//P4温度
uint16_t Temperature_Set_display = 0;//温度设置
uint8_t time_hour_display = 0; //时间 时
uint8_t time_minute_display = 0; //时间 分

static bool last_hengang_state = 0;
static bool last_feed_state = 0;



const bool LED_num_array[15][14]={
	{0,0,1,1,1,1,1,1,1,1,1,1,1,1},//显示‘0’
	{0,0,0,0,0,0,0,0,1,1,1,1,0,0},//显示‘1’
	{1,1,0,0,1,1,1,1,0,0,1,1,1,1},//显示‘2’
	{1,1,0,0,0,0,1,1,1,1,1,1,1,1},//显示‘3’
	{1,1,1,1,0,0,0,0,1,1,1,1,0,0},//显示‘4’
	{1,1,1,1,0,0,1,1,1,1,0,0,1,1},//显示‘5’
	{1,1,1,1,1,1,1,1,1,1,0,0,1,1},//显示‘6’
	{0,0,0,0,0,0,0,0,1,1,1,1,1,1},//显示‘7’
	{1,1,1,1,1,1,1,1,1,1,1,1,1,1},//显示‘8’
	{1,1,1,1,0,0,1,1,1,1,1,1,1,1},//显示‘9’
	{0,0,0,0,0,0,0,0,0,0,0,0,0,0},//显示全关
	{1,1,1,1,1,1,1,1,0,0,0,0,1,1},//显示‘E’
	{1,1,0,0,1,1,0,0,0,0,0,0,0,0},//显示‘r’
	{1,1,0,0,1,1,1,1,1,1,0,0,0,0},//显示‘o’
	{1,1,1,1,1,1,0,0,0,0,0,0,1,1},//显示‘F’
};

const uint8_t LED_time_array[14]={ 
	0x3f,//显示‘0’ 0
	0x06,//显示‘1’和‘I’ 1
	0x5b,//显示‘2’ 2
	0x4f,//显示‘3’ 3
	0x66,//显示‘4’ 4
	0x6d,//显示‘5’ 5
	0x7d,//显示‘6’ 6
	0x07,//显示‘7’ 7
	0x7f,//显示‘8’ 8
	0x6f,//显示‘9’ 9
	0x00,//显示全关
	0x79,//显示‘E’
	0x50,//显示‘r’
	0x5c,//显示‘o’
};

const uint8_t C_or_F[3]={ 
	0x00,//温度图标不显示
	0x37,//温度图标显示摄氏度℃
	0x1f,//温度图标显示华氏度℉
};


//旋钮灯初始化
void Color_led_int(void)
{
	MR88FX02_Gpio_Set_Mode(LED_Red,OUTPUT);
	MR88FX02_Gpio_Set_Mode(LED_Blue,OUTPUT);
	MR88FX02_Gpio_Set_Mode(LED_Yellow,OUTPUT);
	MR88FX02_Gpio_Set_Mode(LED_Orange,OUTPUT);
}



//所有显示
void ALL_display(uint8_t state)
{
	static bool last_fire_state=0;  //火焰图标状态显示
	static bool last_P1_state=0;  //P1状态显示
	static bool last_P2_state=0;  //P1状态显示
	static bool last_P3_state=0;  //P1状态显示
	static bool last_Timer_state=0;  //定时状态显示
	static bool last_starving_state = 0;
	static bool last_SET_state=0;  //SET状态显示
	static bool last_fan_display_state = 0;
	static bool last_motor_display_state = 0;
	static bool last_igniter_display_state = 0;
	static bool last_battery_state = 0;
	static bool last_bluetooth_state = 0;
	static bool last_wifi_state = 0;
	static bool last_logo_state = 0;
	
	static uint16_t last_temp = 0;
	static uint8_t last_state = 0;
	static uint8_t last_Temp_icon_state=0; //温度图标状态 0，不显示  1，摄氏度  2，华氏度
	static uint8_t last_menu_key_state=0; //菜单按键图标状态 0，不显示  1，白色  2，蓝色
	static uint8_t last_feed_key_state=0; //进料按键图标状态 0，不显示  1，白色  2，蓝色
	static uint8_t last_Onoff_key_state=0; //开关按键图标状态 0，不显示  1，白色  2，蓝色

	static uint16_t last_Temperature_P1 = 0;//P1温度
	static uint16_t last_Temperature_P2 = 0;//P2温度
	static uint16_t last_Temperature_P3 = 0;//P3温度
//	static uint16_t last_Temperature_Set = 0;//温度设置
//	static uint8_t last_time_hour = 0; //时间 时
//  static uint8_t last_time_minute = 0; //时间 分
	
	
	static uint16_t last_set_num = 0;
	static uint16_t last_set_num_10 = 0;
	static uint16_t last_set_num_100 = 0;
	
	static uint8_t last_time_hour_num = 0;
	static uint8_t last_time_hour_num_10 = 0;
	
	static uint8_t last_time_minute_num = 0;
	static uint8_t last_time_minute_num_10 = 0;
	
	
	
	static uint16_t num = 0;
	static uint16_t num_10 = 0;
	static uint16_t num_100 = 0;
	
	static uint16_t set_num = 0;
	static uint16_t set_num_10 = 0;
	static uint16_t set_num_100 = 0;
	
	static uint16_t P1_num = 0;
	static uint16_t P1_num_10 = 0;
	static uint16_t P1_num_100 = 0;
	
	static uint16_t P2_num = 0;
	static uint16_t P2_num_10 = 0;
	static uint16_t P2_num_100 = 0;
	
	static uint16_t P3_num = 0;
	static uint16_t P3_num_10 = 0;
	static uint16_t P3_num_100 = 0;
	
	static uint8_t time_hour_num = 0;
	static uint8_t time_hour_num_10 = 0;
	
	static uint8_t time_minute_num = 0;
	static uint8_t time_minute_num_10 = 0;

	static unsigned long OnOff_time=0;
	static unsigned long OnOff_time_last=0;

	OnOff_time = millis();
	
	if(wifi_OnOff)
	{
		if(OnOff_time-OnOff_time_last>SHANSHUO_TIME)
		{
			OnOff_time_last = millis();
			wifi_state = !wifi_state;
		}
	}
	else
	{
		
	}
	
	if(bluetooth_OnOff)
	{
		if(OnOff_time-OnOff_time_last>SHANSHUO_TIME)
		{
			OnOff_time_last = millis();
			bluetooth_state = !bluetooth_state;
		}
	}
	else
	{
		
	}
	
	if(igniter_OnOff)
	{
		if(OnOff_time-OnOff_time_last>SHANSHUO_TIME)
		{
			OnOff_time_last = millis();
			igniter_display_state = !igniter_display_state;
		}
	}
	else
	{
		igniter_display_state = igniter_state;
	}
	
	
	if(motor_OnOff)
	{
		if(OnOff_time-OnOff_time_last>SHANSHUO_TIME)
		{
			OnOff_time_last = millis();
			motor_display_state = !motor_display_state;
		}
	}	
	else
	{
		motor_display_state = motor_state;
	}
	
	if(fan_OnOff)
	{
		if(OnOff_time-OnOff_time_last>SHANSHUO_TIME)
		{
			OnOff_time_last = millis();
			fan_display_state = !fan_display_state;
		}
	}
	else
	{
		fan_display_state = fan_state;
	}
	
	if(Temperature_Set_OnOff)
	{
		if(OnOff_time-OnOff_time_last>SHANSHUO_TIME)
		{
			OnOff_time_last = OnOff_time;
			set_num = 10;
			set_num_10 = 10;
			set_num_100 = 10;
			temp_set_set = !temp_set_set;
		}
	}
	
	if(time_hour_OnOff)
	{
		if(OnOff_time-OnOff_time_last>SHANSHUO_TIME)
		{
			OnOff_time_last = OnOff_time;
			time_hour_num = 10;
			time_hour_num_10 = 10;
			time_hour_set = !time_hour_set;
		}
	}
	
	if(time_minute_OnOff)
	{
		if(OnOff_time-OnOff_time_last>SHANSHUO_TIME)
		{
			OnOff_time_last = OnOff_time;
			time_minute_num = 10;
			time_minute_num_10 = 10;
			time_minute_set = !time_minute_set;
		}
	}


	switch (state)
	{
		case INIT_STATE:
			num = 10;
			num_10 = 10;
			num_100 = 10;
			set_num = 10;
			set_num_10 = 10;
			set_num_100 = 10;
			P1_num = 10;
			P1_num_10 = 10;
			P1_num_100 = 10;
			P2_num = 10;
			P2_num_10 = 10;
			P2_num_100 = 10;
			P3_num = 10;
			P3_num_10 = 10;
			P3_num_100 = 10;
			time_hour_num = 10;
			time_hour_num_10 = 10;
			time_minute_num = 10;
			time_minute_num_10 = 10;
			hengang_state=0;
			menu_key_state=0;
			feed_key_state=0;
			break;
			
			case OFF_STATE:
			if(OnOff_time-OnOff_time_last>500)
		  {
				OnOff_time_last = OnOff_time;
				time_icon = !time_icon;
			}
		 	time_hour_display = time_hour;
			time_minute_display = time_minute;
			Temp_icon_state = 0;
			Temperature_P1 = 0;
			Temperature_P2 = 0;
			Temperature_P3 = 0;
			num = 14;
			num_10 = 14;
			num_100 = 0;
			set_num = 10;
			set_num_10 = 10;
			set_num_100 = 10;
			P1_num = 10;
			P1_num_10 = 10;
			P1_num_100 = 10;
			P2_num = 10;
			P2_num_10 = 10;
			P2_num_100 = 10;
			P3_num = 10;
			P3_num_10 = 10;
			P3_num_100 = 10;
			time_hour_num = time_hour_display%10;
			time_hour_num_10 = time_hour_display/10;
			time_minute_num = time_minute_display%10;
			time_minute_num_10 = time_minute_display/10;
			break;

		case RUN_STATE:
			time_icon = 1;
			hengang_state=1;
			num = Temperature%10;
			num_10 = (Temperature/10)%10;
			num_100 = (Temperature/100)%10;
			if(temp_set_set)
			{
				set_num = Temperature_Set_display%10;
				set_num_10 = (Temperature_Set_display/10)%10;
				set_num_100 = (Temperature_Set_display/100)%10;
			}
			P1_num = Temperature_P1%10;
			P1_num_10 = (Temperature_P1/10)%10;
			P1_num_100 = (Temperature_P1/100)%10;
			P2_num = Temperature_P2%10;
			P2_num_10 = (Temperature_P2/10)%10;
			P2_num_100 = (Temperature_P2/100)%10;
			P3_num = Temperature_P3%10;
			P3_num_10 = (Temperature_P3/10)%10;
			P3_num_100 = (Temperature_P3/100)%10;
			if(time_hour_set)
			{
				time_hour_num = time_hour_display%10;
				time_hour_num_10 = time_hour_display/10;
			}
			if(time_minute_set)
			{
				time_minute_num = time_minute_display%10;
				time_minute_num_10 = time_minute_display/10;
			}
			break;
		
		case ERO_STATE:
			Temp_icon_state = 0;
			num = 13;
			num_10 = 12;
			num_100 = 11;
			set_num = 10;
			set_num_10 = 10;
			set_num_100 = 10;
			P1_num = 10;
			P1_num_10 = 10;
			P1_num_100 = 10;
			P2_num = 10;
			P2_num_10 = 10;
			P2_num_100 = 10;
			P3_num = 10;
			P3_num_10 = 10;
			P3_num_100 = 10;
			time_hour_num = 10;
			time_hour_num_10 = 10;
			time_minute_num = 10;
			time_minute_num_10 = 10;
			break;
		default:break;
	}
	

	
	LED[0][0] = feed_display_state;
	LED[0][1] = feed_display_state;
	LED[0][2] = fan_display_state;
	LED[0][3] = fan_display_state;
	LED[0][4] = motor_display_state;
	LED[0][5] = motor_display_state;
	LED[0][6] = motor_display_state;
	LED[0][7]= igniter_display_state;
	LED[0][8]= igniter_display_state;
	LED[0][9]= igniter_display_state;
	LED[0][10] = battery_state;
	LED[0][11] = battery_state;
	LED[0][12] = bluetooth_state;
	LED[0][13] = bluetooth_state;
	LED[0][14] = wifi_state;
	LED[0][15] = wifi_state;
	
	LED[1][0] = feed_state;
	LED[1][1] = feed_state;
	LED[1][2] = logo_state;
	LED[1][3] = logo_state;
	LED[1][4] = logo_state;
	LED[1][5] = logo_state;
	LED[1][6] = hengang_state;
	LED[1][7]= hengang_state;
	LED[1][8]= hengang_state;
	LED[1][9]= hengang_state;
	LED[1][10] = hengang_state;
	LED[1][11] = hengang_state;
	LED[1][12] = hengang_state;
	LED[1][13] = hengang_state;
	LED[1][14] = hengang_state;
	LED[1][15] = hengang_state;
	
	
	//主显示百位
	LED[3][14] = LED_num_array[num_100][13];
	LED[3][12] = LED_num_array[num_100][12];
	LED[3][11] = LED_num_array[num_100][11];
	LED[5][11] = LED_num_array[num_100][10];
	LED[6][11] = LED_num_array[num_100][9];
	LED[7][11] = LED_num_array[num_100][8];
	LED[2][15] = LED_num_array[num_100][7];
	LED[2][13] = LED_num_array[num_100][6];
	LED[6][15] = LED_num_array[num_100][5];
	LED[7][15] = LED_num_array[num_100][4];
	LED[3][15] = LED_num_array[num_100][3];
	LED[5][15] = LED_num_array[num_100][2];
	LED[5][14] = LED_num_array[num_100][1];
	LED[6][12] = LED_num_array[num_100][0];
		
	//主显示十位
	LED[3][9] = LED_num_array[num_10][13];
	LED[3][7] = LED_num_array[num_10][12];
	LED[3][4] = LED_num_array[num_10][11];
	LED[5][4] = LED_num_array[num_10][10];
	LED[6][4] = LED_num_array[num_10][9];
	LED[7][4] = LED_num_array[num_10][8];
	LED[7][10] = LED_num_array[num_10][7];
	LED[5][0] = LED_num_array[num_10][6];
	LED[5][10] = LED_num_array[num_10][5];
	LED[6][10] = LED_num_array[num_10][4];
	LED[4][11] = LED_num_array[num_10][3];
	LED[3][10] = LED_num_array[num_10][2];
	LED[5][9] = LED_num_array[num_10][1];
	LED[5][7] = LED_num_array[num_10][0];
	
	//主显示个位
	LED[3][6] = LED_num_array[num][13];
	LED[3][2] = LED_num_array[num][12];
	LED[3][1] = LED_num_array[num][11];
	LED[5][1] = LED_num_array[num][10];
	LED[6][1] = LED_num_array[num][9];
	LED[7][1] = LED_num_array[num][8];
	LED[3][0] = LED_num_array[num][7];
	LED[7][2] = LED_num_array[num][6];
	LED[6][5] = LED_num_array[num][5];
	LED[7][5] = LED_num_array[num][4];
	LED[3][5] = LED_num_array[num][3];
	LED[5][5] = LED_num_array[num][2];
	LED[5][6] = LED_num_array[num][1];
	LED[5][2] = LED_num_array[num][0];
	
	LED[2][0] = hengang_state;
	LED[2][1] = hengang_state;
	LED[2][2] = hengang_state;
	LED[2][3] = hengang_state;
	LED[2][4] = hengang_state;
	LED[2][5] = hengang_state;
	LED[2][6] = hengang_state;
	LED[2][7] = hengang_state;
	LED[2][8] = hengang_state;
	LED[2][9] = hengang_state;
	LED[2][10] = ACT_state;
	LED[2][11] = ACT_state;
	
	
	LED[8][8] = LED_time_array[set_num_100]&0x01;
	LED[8][10] = (LED_time_array[set_num_100]>>1)&0x01;
	LED[8][13] = (LED_time_array[set_num_100]>>2)&0x01;
	LED[8][14] = (LED_time_array[set_num_100]>>3)&0x01;
	LED[8][12] = (LED_time_array[set_num_100]>>4)&0x01;
	LED[8][9] = (LED_time_array[set_num_100]>>5)&0x01;
	LED[8][11] = (LED_time_array[set_num_100]>>6)&0x01;
	
	LED[9][0] =  LED_time_array[set_num_10]&0x01;
	LED[9][2] =  (LED_time_array[set_num_10]>>1)&0x01;
	LED[9][5] =  (LED_time_array[set_num_10]>>2)&0x01;
	LED[9][6] =  (LED_time_array[set_num_10]>>3)&0x01;
	LED[9][4] =  (LED_time_array[set_num_10]>>4)&0x01;
	LED[9][1] =  (LED_time_array[set_num_10]>>5)&0x01;
	LED[9][3] =  (LED_time_array[set_num_10]>>6)&0x01;
	
	LED[9][7] =  LED_time_array[set_num]&0x01;
	LED[9][9] =  (LED_time_array[set_num]>>1)&0x01;
	LED[9][12] =  (LED_time_array[set_num]>>2)&0x01;
	LED[9][13] =  (LED_time_array[set_num]>>3)&0x01;
	LED[9][11] =  (LED_time_array[set_num]>>4)&0x01;
	LED[9][8] =  (LED_time_array[set_num]>>5)&0x01;
	LED[9][10] =  (LED_time_array[set_num]>>6)&0x01;
	
	
	
	LED[8][0] = C_or_F[Temp_icon_state]&0x01;
	LED[8][1] = (C_or_F[Temp_icon_state]>>1)&0x01;
	LED[8][2] = (C_or_F[Temp_icon_state]>>2)&0x01;
	LED[8][3] = (C_or_F[Temp_icon_state]>>3)&0x01;
	LED[8][4] = (C_or_F[Temp_icon_state]>>4)&0x01;
	LED[8][5] = (C_or_F[Temp_icon_state]>>5)&0x01;
	
	LED[8][6] = SET_state;
	LED[8][7] = SET_state;
	LED[8][15] = fire_state;
	LED[9][14] = fire_state;
	LED[9][15] = fire_state;
	
	LED[10][2] = LED_time_array[P1_num_100]&0x01;
	LED[10][4] = (LED_time_array[P1_num_100]>>1)&0x01;
	LED[10][7] = (LED_time_array[P1_num_100]>>2)&0x01;
	LED[10][8] = (LED_time_array[P1_num_100]>>3)&0x01;
	LED[10][6] = (LED_time_array[P1_num_100]>>4)&0x01;
	LED[10][3] = (LED_time_array[P1_num_100]>>5)&0x01;
	LED[10][5] = (LED_time_array[P1_num_100]>>6)&0x01;
	
	LED[10][9] =  LED_time_array[P1_num_10]&0x01;
	LED[10][11] =  (LED_time_array[P1_num_10]>>1)&0x01;
	LED[10][14] =  (LED_time_array[P1_num_10]>>2)&0x01;
	LED[10][15] =  (LED_time_array[P1_num_10]>>3)&0x01;
	LED[10][13] =  (LED_time_array[P1_num_10]>>4)&0x01;
	LED[10][10] =  (LED_time_array[P1_num_10]>>5)&0x01;
	LED[10][12] =  (LED_time_array[P1_num_10]>>6)&0x01;
	
	LED[11][0] =  LED_time_array[P1_num]&0x01;
	LED[11][2] =  (LED_time_array[P1_num]>>1)&0x01;
	LED[11][5] =  (LED_time_array[P1_num]>>2)&0x01;
	LED[11][6] =  (LED_time_array[P1_num]>>3)&0x01;
	LED[11][4] =  (LED_time_array[P1_num]>>4)&0x01;
	LED[11][1] =  (LED_time_array[P1_num]>>5)&0x01;
	LED[11][3] =  (LED_time_array[P1_num]>>6)&0x01;
	
	LED[11][8] =  LED_time_array[P2_num_100]&0x01;
	LED[11][10] =  (LED_time_array[P2_num_100]>>1)&0x01;
	LED[11][13] =  (LED_time_array[P2_num_100]>>2)&0x01;
	LED[11][14] =  (LED_time_array[P2_num_100]>>3)&0x01;
	LED[11][12] =  (LED_time_array[P2_num_100]>>4)&0x01;
	LED[11][9] =  (LED_time_array[P2_num_100]>>5)&0x01;
	LED[11][11] =  (LED_time_array[P2_num_100]>>6)&0x01;
	
	LED[12][0] =  LED_time_array[P2_num_10]&0x01;
	LED[12][2] =  (LED_time_array[P2_num_10]>>1)&0x01;
	LED[12][5] =  (LED_time_array[P2_num_10]>>2)&0x01;
	LED[12][6] =  (LED_time_array[P2_num_10]>>3)&0x01;
	LED[12][4] =  (LED_time_array[P2_num_10]>>4)&0x01;
	LED[12][1] =  (LED_time_array[P2_num_10]>>5)&0x01;
	LED[12][3] =  (LED_time_array[P2_num_10]>>6)&0x01;
	
	LED[12][7] =  LED_time_array[P2_num]&0x01;
	LED[12][9] =  (LED_time_array[P2_num]>>1)&0x01;
	LED[12][12] =  (LED_time_array[P2_num]>>2)&0x01;
	LED[12][13] =  (LED_time_array[P2_num]>>3)&0x01;
	LED[12][11] =  (LED_time_array[P2_num]>>4)&0x01;
	LED[12][8] =  (LED_time_array[P2_num]>>5)&0x01;
	LED[12][10] =  (LED_time_array[P2_num]>>6)&0x01;
	

	LED[10][0] = fire_state;
	LED[10][1] = P2_state;
	LED[11][7] = P2_state;
	LED[11][15] = P3_state;
	
	LED[12][14] = Timer_state;
	LED[12][15] = Timer_state;
	
	LED[13][0] =  LED_time_array[P3_num_100]&0x01;
	LED[13][2] =  (LED_time_array[P3_num_100]>>1)&0x01;
	LED[13][5] =  (LED_time_array[P3_num_100]>>2)&0x01;
	LED[13][6] =  (LED_time_array[P3_num_100]>>3)&0x01;
	LED[13][4] =  (LED_time_array[P3_num_100]>>4)&0x01;
	LED[13][1] =  (LED_time_array[P3_num_100]>>5)&0x01;
	LED[13][3] =  (LED_time_array[P3_num_100]>>6)&0x01;
	
	LED[13][7] =  LED_time_array[P3_num_10]&0x01;
	LED[13][9] =  (LED_time_array[P3_num_10]>>1)&0x01;
	LED[13][12] =  (LED_time_array[P3_num_10]>>2)&0x01;
	LED[13][13] =  (LED_time_array[P3_num_10]>>3)&0x01;
	LED[13][11] =  (LED_time_array[P3_num_10]>>4)&0x01;
	LED[13][8] =  (LED_time_array[P3_num_10]>>5)&0x01;
	LED[13][10] =  (LED_time_array[P3_num_10]>>6)&0x01;
	
	LED[13][14] =  time_icon;
	LED[13][15] =  time_icon;
	
	LED[14][0] =  LED_time_array[P3_num]&0x01;
	LED[14][2] =  (LED_time_array[P3_num]>>1)&0x01;
	LED[14][5] =  (LED_time_array[P3_num]>>2)&0x01;
	LED[14][6] =  (LED_time_array[P3_num]>>3)&0x01;
	LED[14][4] =  (LED_time_array[P3_num]>>4)&0x01;
	LED[14][1] =  (LED_time_array[P3_num]>>5)&0x01;
	LED[14][3] =  (LED_time_array[P3_num]>>6)&0x01;
	
	
	
	
	LED[14][7] =  LED_time_array[time_hour_num_10]&0x01;
	LED[14][9] =  (LED_time_array[time_hour_num_10]>>1)&0x01;
	LED[14][12] =  (LED_time_array[time_hour_num_10]>>2)&0x01;
	LED[14][13] =  (LED_time_array[time_hour_num_10]>>3)&0x01;
	LED[14][11] =  (LED_time_array[time_hour_num_10]>>4)&0x01;
	LED[14][8] =  (LED_time_array[time_hour_num_10]>>5)&0x01;
	LED[14][10] =  (LED_time_array[time_hour_num_10]>>6)&0x01;
	
	LED[15][0] =  LED_time_array[time_hour_num]&0x01;
	LED[15][2] =  (LED_time_array[time_hour_num]>>1)&0x01;
	LED[15][5] =  (LED_time_array[time_hour_num]>>2)&0x01;
	LED[15][6] =  (LED_time_array[time_hour_num]>>3)&0x01;
	LED[15][4] =  (LED_time_array[time_hour_num]>>4)&0x01;
	LED[15][1] =  (LED_time_array[time_hour_num]>>5)&0x01;
	LED[15][3] =  (LED_time_array[time_hour_num]>>6)&0x01;




	LED[15][7] =  LED_time_array[time_minute_num_10]&0x01;
	LED[15][9] =  (LED_time_array[time_minute_num_10]>>1)&0x01;
	LED[15][12] =  (LED_time_array[time_minute_num_10]>>2)&0x01;
	LED[15][13] =  (LED_time_array[time_minute_num_10]>>3)&0x01;
	LED[15][11] =  (LED_time_array[time_minute_num_10]>>4)&0x01;
	LED[15][8] =  (LED_time_array[time_minute_num_10]>>5)&0x01;
	LED[15][10] =  (LED_time_array[time_minute_num_10]>>6)&0x01;
	
	LED[16][0] =  LED_time_array[time_minute_num]&0x01;
	LED[16][2] =  (LED_time_array[time_minute_num]>>1)&0x01;
	LED[16][5] =  (LED_time_array[time_minute_num]>>2)&0x01;
	LED[16][6] =  (LED_time_array[time_minute_num]>>3)&0x01;
	LED[16][4] =  (LED_time_array[time_minute_num]>>4)&0x01;
	LED[16][1] =  (LED_time_array[time_minute_num]>>5)&0x01;
	LED[16][3] =  (LED_time_array[time_minute_num]>>6)&0x01;
	
	LED[14][14] = starving_state;
	LED[14][15] = starving_state;
	LED[15][14] = starving_state;
	LED[15][15] = starving_state;
	LED[16][7] = starving_state;
	LED[16][8] = starving_state;


  LED[16][9] = Onoff_key_state&0x01;
	LED[16][10] = Onoff_key_state&0x01;
	LED[16][11] = (Onoff_key_state>>1)&0x01;
	LED[16][12] = (Onoff_key_state>>1)&0x01;
	
	LED[17][0] = Onoff_key_state&0x01;
	LED[17][1] = Onoff_key_state&0x01;
	LED[17][2] = Onoff_key_state&0x01;
	LED[17][3] = Onoff_key_state&0x01;
	
	LED[18][0] = (Onoff_key_state>>1)&0x01;
	LED[18][1] = (Onoff_key_state>>1)&0x01;
	LED[18][2] = (Onoff_key_state>>1)&0x01;
	LED[18][3] = (Onoff_key_state>>1)&0x01;
	
	
	LED[17][4] = menu_key_state&0x01;
	LED[17][5] = menu_key_state&0x01;
	LED[17][6] = menu_key_state&0x01;
	LED[17][7] = menu_key_state&0x01;
	LED[17][8] = menu_key_state&0x01;
	LED[17][9] = menu_key_state&0x01;
	
	LED[18][4] = (menu_key_state>>1)&0x01;
	LED[18][5] = (menu_key_state>>1)&0x01;
	LED[18][6] = (menu_key_state>>1)&0x01;
	LED[18][7] = (menu_key_state>>1)&0x01;
	LED[18][8] = (menu_key_state>>1)&0x01;
	LED[18][9] = (menu_key_state>>1)&0x01;
	
	LED[17][10] = feed_key_state&0x01;
	LED[17][11] = feed_key_state&0x01;
	LED[17][12] = feed_key_state&0x01;
	LED[17][13] = feed_key_state&0x01;
	LED[17][14] = feed_key_state&0x01;
	LED[17][15] = feed_key_state&0x01;
	
	LED[18][10] = (feed_key_state>>1)&0x01;
	LED[18][11] = (feed_key_state>>1)&0x01;
	LED[18][12] = (feed_key_state>>1)&0x01;
	LED[18][13] = (feed_key_state>>1)&0x01;
	LED[18][14] = (feed_key_state>>1)&0x01;
	LED[18][15] = (feed_key_state>>1)&0x01;
	
	
	if(last_feed_state!=feed_state||last_fan_display_state!=fan_display_state||last_motor_display_state!=motor_display_state||
		last_feed_state!=feed_state||last_logo_state!=logo_state||last_hengang_state!=hengang_state||
	last_igniter_display_state!=igniter_display_state||last_battery_state!=battery_state||
	last_bluetooth_state!=bluetooth_state||last_wifi_state!=wifi_state||
	(last_temp!=Temperature)||(last_hengang_state!=hengang_state)||(last_state!=state))
	{
		last_logo_state=logo_state;
		last_hengang_state=hengang_state;
		last_feed_state=feed_state;
		last_fan_display_state=fan_display_state;
		last_motor_display_state=motor_display_state;
		last_igniter_display_state=igniter_display_state;
		last_battery_state=battery_state;
		last_bluetooth_state=bluetooth_state;
		last_wifi_state=wifi_state;
		last_temp = Temperature;
		last_state = state;
		AiP1632C_write(0x00,8);
	}
	
	if((last_set_num_100!=set_num_100)||(last_set_num_10!=set_num_10)||(last_set_num!=set_num)||(last_Temp_icon_state!=Temp_icon_state)||(last_SET_state!=SET_state)
		||(last_fire_state!=fire_state))
	{
		last_set_num_100=set_num_100;
		last_set_num_10=set_num_10;
		last_set_num=set_num;
		last_Temp_icon_state=Temp_icon_state;
		last_SET_state=SET_state;
		last_fire_state=fire_state;
		
		AiP1632C_write(0x20,2);//更新显示
	}
	else
	{
	}
	
	
	if((last_Temperature_P1!=Temperature_P1)||(last_Temperature_P2!=Temperature_P2)||(last_fire_state!=fire_state)
		||(last_P1_state!=P1_state)||(last_P2_state!=P2_state)||(last_Timer_state!=Timer_state)||(last_P3_state!=P3_state))
	{
		last_Temperature_P1=Temperature_P1;
		last_Temperature_P2=Temperature_P2;
		last_fire_state=fire_state;
		last_P1_state=P1_state;
		last_P2_state=P2_state;
		last_Timer_state=Timer_state;
		last_P3_state=P3_state;
		AiP1632C_write(0x28,3);//更新显示
	}
	else
	{
	}

	
	if((last_time_minute_num!=time_minute_num)||(last_time_minute_num_10!=time_minute_num_10)
		||(last_time_hour_num!=time_hour_num)||(last_time_hour_num_10!=time_hour_num_10)
	||(last_Temperature_P3!=Temperature_P3)||(last_starving_state!=starving_state)
	||(last_Onoff_key_state!=Onoff_key_state)||(last_feed_key_state!=feed_key_state)
	||(last_menu_key_state!=menu_key_state))
	{
		last_time_minute_num=time_minute_num;
		last_time_minute_num_10=time_minute_num_10;
		last_time_hour_num=time_hour_num;
		last_time_hour_num_10=time_hour_num_10;
		last_Temperature_P3=Temperature_P3;
		last_starving_state=starving_state;
		last_Onoff_key_state=Onoff_key_state;
		last_feed_key_state=feed_key_state;
		last_menu_key_state=menu_key_state;
		
		AiP1632C_write(0x34,6);//更新显示
	}
	else
	{
	}
	
	
}










































